<template>
	<view>
		
        <view class="first_tab">
           <view class="goods_item"
			v-for="(item,index) in goodsList1"
			>
			<!-- 左图片 -->
                <view class="goods_img_wrap" @click="navigatorTo1(item.id)">
					<view class="imgRadius">
						 <image mode="widthFix" :src="item.firstPicUrl"> </image>
					</view>
                </view>
           <!-- 右信息 -->
                <view class="goods_info_wrap"  @click="navigatorTo1(item.id)">
                    <view class="goods_name">{{item.name}}</view>
                    <view class="goods_price">￥{{item.price}}</view>
					<view class="goods_createTime">发布时间:{{item.createTime}}</view>
                </view>
				
				<view class="statusBut">
					<image  src="http://1.14.247.152:9797/images/16615xiajia.png" mode="widthFix" @click="soldOutFun(item.id,index)"></image>
				</view>
            </view>
				
        </view>
	</view>
</template>

<script>
	export default {
		name:"goodsList",
		props: {
			goodsList: {
				type: Array
			},
			
		},
		computed:{
			goodsList1:{
				get(){
					console.log('goodsList1里面的get()')
					return this.goodsList;
				},
				set(value){
					console.log('goodsList1被修改了！！！',value)
					//value是被删的数组元素
					// this.goodsList=value
					this.$forceUpdate()
				}
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
				async soldOutFun(id,index){
					let header = new Object
					header.Authority = getApp().globalData.Authority
					wx.showModal({
					  title: '提示',
					  content: '是否确认下架?',
					  success: async(res)=> {
					    if (res.confirm) {
							let data = await getApp().UniRequest('/twohandbook/goods/authority?id='+id,'DELETE','',header)
							console.log('下架闲置物品res',data)
							if(data.code==20000){
								this.goodsList1= this.goodsList1.splice(index,1)
								// this.$forceUpdate()
								console.log('this.goodsList33333',this.goodsList)
								wx.showToast({
								  title: '下架成功',
								  icon: 'success',
								  duration: 800
								})
							}
					    } else if (res.cancel) {
						  console.log('点击了取消')
					    }
					  }
					})
				},		
				navigatorTo1(id){
					console.log('***000000000000000')
					uni.navigateTo({
						url:"/pages/goodsDetail/goodsDetail?goodId="+id
					})
				},		
			},
		}
	
</script>

<style lang="scss">
	.first_tab{
	    .goods_item{
	        display: flex;
	        // border-bottom: .1rpx solid #ccc;
			padding: 10rpx 0;
			width: 93%;
			margin: auto;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			box-shadow: 0.5rpx 0.5rpx 40rpx #DBDBDB;
	        .goods_img_wrap{
	            flex: 2;
				height: 200rpx;
	            display: flex;
				justify-content: center;
				.imgRadius{
					width: 70%;
					height: 100%;
					border-radius: 18rpx;
					display: flex;
					overflow: hidden;
					justify-content: center;
					align-items: center;
				}
	            image{
	                width: 100%;
	            } 
	        }
	        .goods_info_wrap{
	            flex: 3;
	            display: flex;
	            flex-direction:column ;
	            justify-content: space-around;
	            .goods_name{
	                display: -webkit-box;
	                width: 310rpx;
	                overflow: hidden;
	                -webkit-box-orient: vertical;
	                -webkit-line-clamp: 2;
	                text-overflow: ellipsis;
	            }
	            .goods_price{
	                color: #fd4f02;
	                font-size: 38rpx;
	            }
				.goods_createTime{
					font-size: 25rpx;
					white-space: nowrap;
				}
	        }
			.statusBut{
				flex: 1;
				display: flex;
				justify-content: left;
				align-items: center;
				image{
					width: 69%;
				}
			}
	    }
	
	}
</style>
